package com.example.interpreter;

import java.util.ArrayList;
import java.util.Map;

public class AndExpression implements Expression {
    
    private ArrayList<Expression> expressions = new ArrayList<>();

    public AndExpression(String rule) {
        for (String s : rule.split("&&")) {
            if (s.contains(">")) {
                expressions.add(new GratterExpression(s));
            }
        }
    }

    @Override
    public boolean interpret(Map<String, Integer> stat) {
        for (Expression e : this.expressions) {
            if (!e.interpret(stat)) {
                return false;
            }
        }
        return true;
    }

}
